#ifndef __REF_COUNTED_H_
#define __REF_COUNTED_H_

#include <assert.h>
namespace KEngine
{
	
	class RefCounted
	{
	public:

		RefCounted() : _count(1)
		{

		}
		
		virtual ~RefCounted()
		{
			assert(_count==0);
		}
		  
		unsigned int getRefCount(){return _count;}

		void addRef()
		{
			++_count;
		}

		void Release()
		{
			if (!--_count)
			{
				delete this;
			}
		}

		protected:
		unsigned int _count;  
	};


};

#endif